import sys
from PyQt5 import QtWidgets
from score import *


class Ui_DockWidget_Impl:
    def __init__(self, ui_designer):
        self.ui = ui_designer
        self.callback_init()

    def callback_init(self):
        self.ui.btn_add.clicked.connect(self.button_add_calculate)

    def button_add_calculate(self):
        physics_score_text = self.ui.input_pyhsics.text()
        math_score_text = self.ui.input_math.text()
        if len(physics_score_text) == 0 or len(math_score_text) == 0:
            print("请输入完整信息")
            return
        pyhsics_score = int(physics_score_text)
        math_score = int(math_score_text)
        total = pyhsics_score + math_score
        self.ui.output_total.setText(str(total))


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    DockWidget = QtWidgets.QDockWidget()
    ui = Ui_DockWidget()
    ui.setupUi(DockWidget)
    ui_impl = Ui_DockWidget_Impl(ui)
    DockWidget.show()
    sys.exit(app.exec_())
